import { CustomComponent } from '/engine/index';

CustomComponent({
  options: {},
  properties: {
    title: {
      type: String,
      value: '默认标题',
    },
    showBack: {
      type: Boolean,
      value: true,
    },
  },
  data: {
    titleTop: 0,
    navHeight: 0,
  },
  lifetimes: {
    attached() {
      const menuButtonInfo = wx.getMenuButtonBoundingClientRect();

      this.setData({
        navHeight: menuButtonInfo.height,
        titleTop: menuButtonInfo.top,
      });
    },
  },
  methods: {
    onTapBack() {
      this.triggerEvent('back'); // 触发 back 事件
    },
  },
});
